<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>系统设置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
    <style>
        .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
    </style>
</head>
<body>
    <div class="layuimini-container">
    	
        <div class="layuimini-main">
        	<div style="text-align:right">
        		<a class="layui-btn" href="/part/excel">导出生成excel</a>
        	</div>
    		<hr>
            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    
        </div>
    </div>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        var showData = function(){
        	window.setTimeout(showData,6000);
        	console.log('showData函数执行啦')
        	table.render({
                elem: '#currentTableId',
                url: '/part/listener',
                cols: [[
                        {type: "checkbox", width: 50},
                        {field: 'id', title: '配件编号', sort: true},
                        {field: 'name', title: '配件名字'},
                        {field: 'brand', title: '品牌'},
                        {field: 'type', title: '型号'},
                        {field: 'buyPrice', title: '进货单价'},
                        {field: 'sellPrice', title: '零售单价'},
                        {field: 'count', title: '剩余数量'},
                        {field: 'listener', title: '报警数量'},
                        {field: 'providerName', title: '供货商'},
                        {field: 'providerPhone',width:200, title: '联系方式'}
                    ]],
                    limits: [10, 15, 20, 25, 50, 100],
                    limit: 15,
                    page: true,
                    skin: 'line',
                    parseData:function(res){
                    	for(p of res.list){
                    		p.providerName = p.provider.name;
                    		p.providerPhone = p.provider.phone;
                    	}
                    	return {
                    		"code":0,
                    		"msg":"",
                    		"count":res.count,
                    		"data":res.list
                    	}
                    }
            });
        }
        showData();
        //window.setInterval(showData,1000*60*60);
        //window.setTimeout(函数名字,数字 单位是毫秒)   让指定函数 在指定时间之后 执行一次
        //window.setInterval(函数名字,数字 单位是毫秒)  让指定的函数  每隔多少时间 都执行一次
        
    });
</script>
</body>
</html>